<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>Document</title>
	<script type="text/javascript">
		window.onload = function(){

			var oDiv = document.getElementById('div1');

			

			changestyle('color','gold');
			changestyle('background','red');
			changestyle('width','300px');
			changestyle('height','300px');
			changestyle('fontSize','30px');













			function changestyle(styl,val){				
				oDiv.style[styl] = val;
			}


		}



	</script>
</head>
<body>
	<div id="div1">div元素</div>
</body>
</html>